﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DatabaseAccessLayer;
using System.Configuration;
using SavoryBL;
using System.Data;

namespace WebApplication.administrator
{
    public partial class My_Profile : System.Web.UI.Page
    {
        SavoryAdminAccount adminAccountObj = new SavoryAdminAccount();
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    if (Session["Admin"] != null && Session["Admin"].ToString() != "")
                    {
                        DataSet ds = adminAccountObj.GetAdminProfileDetails(Convert.ToInt32(Session["AdminID"].ToString()), Session["Admin"].ToString());
                        if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                        {
                            txt_EmailID.Text = ds.Tables[0].Rows[0]["EmailID"].ToString();
                            txt_UserName.Text = ds.Tables[0].Rows[0]["UserName"].ToString();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }

        protected void btn_UpdateProfile_Click(object sender, EventArgs e)
        {
            try
            {
                if (Session["Admin"] != null && Session["Admin"].ToString() != "")
                {
                    SavoryAdminAccount adminAccountObj = new SavoryAdminAccount();
                    ResponseStatus status = ResponseStatus.Failure;
                    status = adminAccountObj.AdminUpdateProfile(Convert.ToInt32(Session["AdminID"].ToString()), txt_EmailID.Text.Trim(), txt_UserName.Text.Trim(), txt_Password.Text.Trim(), Session["Admin"].ToString());
                    if (status == ResponseStatus.Success)
                    {
                        div_UpdateProfileMsg.Style["display"] = "block";
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
    }
}